{include file="public/page_header" /} <!--头部公共区域-->

<div class="layui-layout layui-layout-admin">
    <form action="" class="layui-form">
        <input type="hidden" value="{$data.id}" name="id">
        <div class="layui-form-item">
            <label class="layui-form-label">用户名</label>
            <div class="layui-input-block">
                <input type="text" name="admin_name" required  lay-verify="required" autocomplete="off" class="layui-input" value="{$data.admin_name}" disabled>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">名称</label>
            <div class="layui-input-block">
                <input type="text" name="truename" required  lay-verify="required" autocomplete="off" class="layui-input" value="{$data.truename}" disabled>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">密码</label>
            <div class="layui-input-block">
                <input type="password" name="admin_pwd" required  lay-verify="required" autocomplete="off" class="layui-input" placeholder="密码">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">确认密码</label>
            <div class="layui-input-block">
                <input type="password" name="admin_pwd2" required  lay-verify="required" autocomplete="off" class="layui-input" placeholder="确认密码">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"></label>
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="formDemo" id="formDemo">立即提交</button>
            </div>
        </div>
    </form>
</div>

{include file="public/page_footer" /} <!--尾部公共区域-->

<script type="text/javascript">
    layui.use('form', function(){
        var form = layui.form;
        //监听提交
        form.on('submit(formDemo)', function(data){
            $pass = $("input[name='admin_pwd']").val();
            $pass2 = $("input[name='admin_pwd2']").val();
            if ($pass != $pass2){
                top.layer.msg("两次密码不一致")
                return false;
            }
            $.ajax({
                type : "POST",  //提交方式
                url : "{:url('admin/uppass')}",//路径
                data : $('form').serialize(),
                success: function(data){
                    top.layer.msg(data.msg,{icon: 6,time: 2000})
                    if(data.code == 0){
                        var  index= parent.layer.getFrameIndex(window.name);
                        setTimeout(function () {
                            parent.layer.close(index);
                        }, 2000);
                    }
                }
            });
            return false;
        });
    });
</script>

